//
//  YDAModifyPasswordController.m
//  siyanone
//
//  Created by LK-IOS on 2018/3/26.
//  Copyright © 2018年 LK-News. All rights reserved.
//

#import "YDAModifyPasswordController.h"

@interface YDAModifyPasswordController ()<UITextFieldDelegate>

//电话图标
@property (nonatomic , weak) UIImageView *phoneImage;
//号码输入框
@property (nonatomic , weak) SYPhoneTextField *phoneTextField;
//号码下划线
@property (nonatomic , weak) UIView *phoneLineView;
//验证码下划线
@property (nonatomic , weak) UIView *codeLineView;
//获取验证码按钮
@property (nonatomic , weak) SYNoHeightedButton *codeButton;
//验证码输入框
@property (nonatomic , weak) UITextField *codeTextField;
//密码图标
@property (nonatomic , weak) UIImageView *passImage;
//密码输入框
@property (nonatomic , weak) UITextField *passTextField;
//密码下划线
@property (nonatomic , weak) UIView *passLineView;
//密码可见按钮
@property (nonatomic , weak) SYNoHeightedButton *passButton;
//密码提示文字
@property (nonatomic , weak) UILabel *passPostLabel;
//确认按钮
@property (nonatomic , weak) SYNoHeightedButton *sureButton;

//用户输入的手机号和密码
@property (nonatomic , copy) NSString *userPhoneNumber;
@property (nonatomic , copy) NSString *userPassCode;
@property (nonatomic , copy) NSString *code;


@end

@implementation YDAModifyPasswordController

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"修改密码";
    
    //给界面添加点击手势，点击退出编辑
    [self dismissKeyBoard];
    
    
    [self addChildViews];
    
    //默认给当前手机号
    [self placeHoderPhone];
    
    //给输入框添加监听，控制登录按钮是否可以点击
    [self.phoneTextField addTarget:self action:@selector(textchange) forControlEvents:UIControlEventAllEditingEvents];
    [self.codeTextField addTarget:self action:@selector(textchange) forControlEvents:UIControlEventAllEditingEvents];
    [self.passTextField addTarget:self action:@selector(textchange) forControlEvents:UIControlEventAllEditingEvents];
}

- (void)placeHoderPhone
{
    NSString *phone =  [SYUserDataManger sharedInstance].getUerPhone.length?[SYUserDataManger sharedInstance].getUerPhone : @"";
    self.phoneTextField.text = [NSString phoneNumberFormate:phone];
    [self textchange];
}

-(void)textchange
{
    self.sureButton.enabled = self.phoneTextField.text.length && self.passTextField.text.length && self.codeTextField.text.length;
    self.codeButton.enabled = self.phoneTextField.text.length;
}

//添加子控件
-(void)addChildViews
{
    [self phoneLineView];
    [self phoneImage];
    [self phoneTextField];
    [self codeLineView];
    [self codeButton];
    
    [self codeTextField];
    
    [self passLineView];
    [self passImage];
    [self passButton];
    [self passTextField];
    [self passPostLabel];
    [self sureButton];
}
//////***********点击事件**************////
//获取验证码按钮
-(void)codeButtonClick
{
    [self.view endEditing:YES];
    
    self.userPhoneNumber = [self.phoneTextField.text stringByReplacingOccurrencesOfString:@" " withString:@""];
    
    if (![NSString isPhoneNumber:self.userPhoneNumber]) {
        
        [[NavTipsView defaultTipsView] showTipsBannerInView:self.view
                                                        WithType:NavTipsViewTypeMessage
                                                            text:@"请输入正确的手机号"
                                                      isExistNav:YES];
        
        return;
    }else{
        [self getCodeRequest];
        //获取验证码
        [self.codeButton openCountdown];
    }
    
    
}

//确认按钮
-(void)sureButtonClick:(SYNoHeightedButton *)button
{
    [self.view endEditing:YES];
    self.userPhoneNumber = [self.phoneTextField.text stringByReplacingOccurrencesOfString:@" " withString:@""];
    self.code = self.codeTextField.text;
    self.userPassCode = self.passTextField.text;
    
    if (![NSString isPhoneNumber:self.userPhoneNumber]) {
        
        [[NavTipsView defaultTipsView] showTipsBannerInView:self.view
                                                        WithType:NavTipsViewTypeMessage
                                                            text:@"请输入正确的手机号"
                                                      isExistNav:YES];
        return;
    }else if (![NSString isAllNum:self.code]){
        [[NavTipsView defaultTipsView] showTipsBannerInView:self.view
                                                        WithType:NavTipsViewTypeMessage
                                                            text:@"请输入正确的验证码"
                                                      isExistNav:YES];
        return;
    }
    else if (![NSString judgePassWordLegal:self.userPassCode])
    {
        [[NavTipsView defaultTipsView] showTipsBannerInView:self.view
                                                        WithType:NavTipsViewTypeMessage
                                                            text:@"密码为数字和字母组合，6~12位"
                                                      isExistNav:YES];
        return;
    }
    
    else{
        [self sendUserInformation];
    }
    
}

-(void)getCodeRequest
{
    [[SYProgressHUD sharedInstance] showMBHudBackViewLoading];
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
    [dict setObject:self.userPhoneNumber forKey:@"phone"];
    [dict setObject:@(2) forKey:@"type"];
    
    [BaseNetRequest sessionRequestWithparameters:dict method:POSTMethod requstType:GetCodeNumber WithSuccessBlock:^(NSDictionary *resultDict) {
        [[SYProgressHUD sharedInstance] dismissMBWithTime:0];

        if ([resultDict[@"code"] integerValue] == 200) {
            self.codeButton.isSuccessSendCode = YES;
        }else{
            self.codeButton.isSuccessSendCode = NO;
        }
        if ([resultDict[@"code"] integerValue] == 200) {//成功
            [[NavTipsView defaultTipsView] showTipsBannerInView:self.view
                                                            WithType:NavTipsViewTypeMessage
                                                                text:@"验证码已发送，请注意查收"
                                                          isExistNav:YES];
        }else if ([resultDict[@"code"] integerValue] == 2002){//短信发送间隔太短
            [[NavTipsView defaultTipsView] showTipsBannerInView:self.view
                                                            WithType:NavTipsViewTypeMessage
                                                                text:resultDict[@"message"]
                                                          isExistNav:YES];
        }else if ([resultDict[@"code"] integerValue] == 2007){//手机号码尚未注册
            [[NavTipsView defaultTipsView] showTipsBannerInView:self.view
                                                            WithType:NavTipsViewTypeMessage
                                                                text:resultDict[@"message"]
                                                          isExistNav:YES];
        }else{
            [[NavTipsView defaultTipsView] showTipsBannerInView:self.view
                                                            WithType:NavTipsViewTypeMessage
                                                                text:resultDict[@"message"]
                                                          isExistNav:YES];
        }
    } failBlock:^(NSError *error) {
        DDLog(@"error = %@",error)
        self.codeButton.isSuccessSendCode = NO;
        [[SYProgressHUD sharedInstance] dismissMBWithTime:0];
        [[NavTipsView defaultTipsView] showTipsBannerInView:self.view
                                                        WithType:NavTipsViewTypeMessage
                                                            text:@"验证码发送失败，请稍后重试"
                                                      isExistNav:YES];
    }];
    
    
}
-(void)sendUserInformation
{
    [[SYProgressHUD sharedInstance] showMBHudBackViewLoading];
    
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
    
    [dict setObject:self.userPhoneNumber forKey:@"phone"];
    [dict setObject:self.code forKey:@"verificationCode"];
    [dict setObject:self.userPassCode forKey:@"password"];
    
    [BaseNetRequest sessionRequestWithparameters:dict method:POSTMethod requstType:ModifyPassword WithSuccessBlock:^(NSDictionary *resultDict) {
        DDLog(@"修改密码成功信息%@",resultDict);
        [[SYProgressHUD sharedInstance] dismissMBWithTime:0];
        
        if ([resultDict[@"code"] integerValue] == 200) {//注册成功
            [self resloveUserInformationWithDict:resultDict[@"result"]];//处理一下用户信息
            [[NavTipsView defaultTipsView] showTipsBannerInView:self.view
                                                            WithType:NavTipsViewTypeMessage
                                                                text:@"密码修改成功"
                                                          isExistNav:YES];
            
        }else{
            
            
            [[NavTipsView defaultTipsView] showTipsBannerInView:self.view WithType:NavTipsViewTypeMessage text:resultDict[@"message"] isExistNav:YES];
        }
    } failBlock:^(NSError *error) {
        [[SYProgressHUD sharedInstance] dismissMBWithTime:0];
        [[NavTipsView defaultTipsView] showTipsBannerInView:self.view
                                                        WithType:NavTipsViewTypeMessage
                                                            text:@"密码修改失败，请稍后重试"
                                                      isExistNav:YES];
    }];
    
    
}

-(void)resloveUserInformationWithDict:(NSDictionary *)dict
{
    [[SYUserDataManger sharedInstance] storeUserDataWithDict:dict];
    [[SYUserDataManger sharedInstance] storeUserToken:dict[@"token"]];
    
    [SYUserInformation sharedInstance].isLogin = YES;
    
    [self.navigationController popViewControllerAnimated:YES];
    
}

-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
    if ([textField isFirstResponder]) {
        
        if ([[[textField textInputMode] primaryLanguage] isEqualToString:@"emoji"] || ![[textField textInputMode] primaryLanguage]) {
            return NO;
        }
        
        
    }
    if (textField == _phoneTextField) {
        //字符个数限制
        NSString * toBeString = [textField.text stringByReplacingCharactersInRange:range withString:string];
        if ([toBeString length] > 13) {
            
            return NO;
        }
        //忽略空格
        if([string hasSuffix:@" "]){
            // 忽视空格
            return NO;
        }else{
            return YES;
        }
        
    }else{
        //密码输入框处理
        //字符个数限制
        NSString * passString = [textField.text stringByReplacingCharactersInRange:range withString:string];
        if ([passString length] > 12) {
            
            return NO;
        }
        //忽略小数点和空格
        if([string isEqualToString:@"."] || [string hasSuffix:@" "]){
            // 忽视空格
            return NO;
        }else{
            return YES;
        }
        
    }
    
    return YES;
}

///*********添加控件部分***********/////
///**********号码下划线********///
-(UIView *)phoneLineView
{
    if (_phoneLineView == nil) {
        UIView *phoneLineView = [[UIView alloc] init];
        [self.view addSubview:phoneLineView];
        //236 231 231
        phoneLineView.backgroundColor = NumberColor(236, 231, 231);
        [phoneLineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.view).offset(rate375(20));
            make.right.equalTo(self.view).offset(-rate375(20));
            make.centerX.equalTo(self.view);
            make.height.equalTo(@1);
            if (isPhoneX) {
                make.top.equalTo(self.view).offset(rateX812(80));
            }else{
                make.top.equalTo(self.view).offset(rate750(60));
            }
        }];
        _phoneLineView = phoneLineView;
    }
    return _phoneLineView;
}
///*********电话图标*********///
-(UIImageView *)phoneImage
{
    if (_phoneImage == nil) {
        UIImageView *phoneImage = [[UIImageView alloc] init];
        [self.view addSubview:phoneImage];
        phoneImage.backgroundColor = [UIColor clearColor];
        phoneImage.image = [UIImage imageNamed:@"dl-shouji"];
        phoneImage.contentMode = UIViewContentModeScaleToFill;
        [phoneImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.view).offset(rate375(25));
            make.width.equalTo(@(rate375(12)));
            if (isPhoneX) {
                make.height.equalTo(@(rateX812(16)));
                make.bottom.equalTo(self.phoneLineView.mas_top).offset(-rateX812(10));
            }else{
                make.height.equalTo(@(rate750(16)));
                make.bottom.equalTo(self.phoneLineView.mas_top).offset(-rate750(10));
            }
        }];
        _phoneImage = phoneImage;
    }
    return _phoneImage;
}
///********号码输入框**********///
-(SYPhoneTextField *)phoneTextField
{
    if (_phoneTextField == nil) {
        SYPhoneTextField *phoneTextField = [[SYPhoneTextField alloc] init];
        [self.view addSubview:phoneTextField];
        phoneTextField.textColor = [UIColor blackColor];
        phoneTextField.font = [UIFont systemFontOfSize:font14ScreenWRate * LKScreenW];
        phoneTextField.placeholder = @"请输入手机号码";
        phoneTextField.enabled = NO;
        phoneTextField.backgroundColor = [UIColor clearColor];
        phoneTextField.borderStyle = UITextBorderStyleNone;
        phoneTextField.textAlignment = NSTextAlignmentLeft;
        phoneTextField.keyboardType = UIKeyboardTypeNumberPad;
        phoneTextField.autocapitalizationType = UITextAutocapitalizationTypeNone;
        phoneTextField.keyboardAppearance=UIKeyboardAppearanceDefault;
        phoneTextField.returnKeyType =UIReturnKeyDone;
        [phoneTextField setClearButtonMode:UITextFieldViewModeWhileEditing];
        [phoneTextField mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.phoneImage);
            make.left.equalTo(self.phoneImage.mas_right).offset(rate375(13));
            make.right.equalTo(self.phoneLineView);
            if (isPhoneX) {
                make.height.equalTo(@(rateX812(20)));
            }else{
                make.height.equalTo(@(rate750(20)));
            }
        }];
        phoneTextField.tintColor = [UIColor blackColor];
        phoneTextField.delegate = self;
        
        //        [phoneTextField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
        
        _phoneTextField = phoneTextField;
    }
    return _phoneTextField;
}
//限制号码输入框的字符个数限制
//- (void)textFieldDidChange:(UITextField *)textField
//{
//    if (textField == self.phoneTextField) {
//        if (textField.text.length > 11) {
//            textField.text = [textField.text substringToIndex:11];
//            //#warning 提示输入11位有效手机号码
//            [[PZProgressHUD sharedInstance] showSVOnlytextWithText:@"请输入11位有效手机号"];
//            [[PZProgressHUD sharedInstance] dismissSVWithTime:1];
//        }
//    }
//}

-(UIView *)codeLineView
{
    if (_codeLineView == nil) {
        UIView *codeLineView = [[UIView alloc] init];
        [self.view addSubview:codeLineView];
        //236 231 231
        codeLineView.backgroundColor = NumberColor(236, 231, 231);
        [codeLineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.view).offset(rate375(20));
            make.right.equalTo(self.view).offset(-rate375(175));
            make.height.equalTo(@1);
            if (isPhoneX) {
                make.top.equalTo(self.phoneLineView.mas_bottom).offset(rateX812(52));
            }else{
                make.top.equalTo(self.phoneLineView.mas_bottom).offset(rate750(52));
            }
        }];
        
        _codeLineView = codeLineView;
    }
    return _codeLineView;
}
//获取验证码按钮
-(SYNoHeightedButton *)codeButton
{
    if (_codeButton == nil) {
        SYNoHeightedButton *codeButton = [SYNoHeightedButton buttonWithType:UIButtonTypeCustom];
        [self.view addSubview:codeButton];
        codeButton.enabled = NO;
        codeButton.titleLabel.textAlignment = NSTextAlignmentCenter;
        [codeButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [codeButton setTitleColor:[UIColor whiteColor] forState:UIControlStateDisabled];
        [codeButton setBackgroundImage:[UIImage imageWithColor:zhidainMainColor] forState:UIControlStateNormal];
        [codeButton setBackgroundImage:[UIImage imageWithColor:zhidianAlprColor(0.3)] forState:UIControlStateDisabled];
        [codeButton setTitle:@"发送验证码" forState:UIControlStateNormal];
        [codeButton setTitle:@"发送验证码" forState:UIControlStateDisabled];
        codeButton.titleLabel.font = [UIFont systemFontOfSize:font14ScreenWRate * LKScreenW];
        [codeButton mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.right.equalTo(self.view).offset(-rate375(20));
            make.width.equalTo(@(rate375(140)));
            make.bottom.equalTo(self.codeLineView.mas_top);
            if (isPhoneX) {
                make.height.equalTo(@(rateX812(40)));
            }else{
                make.height.equalTo(@(rate750(40)));
            }
            
        }];
        [codeButton addTarget:self action:@selector(codeButtonClick) forControlEvents:UIControlEventTouchDown];
        codeButton.layer.cornerRadius = 5;
        codeButton.layer.masksToBounds = YES;
        
        _codeButton = codeButton;
    }
    return _codeButton;
}

//验证码输入框
-(UITextField *)codeTextField
{
    if (_codeTextField == nil) {
        UITextField *codeTextField = [[UITextField alloc] init];
        [self.view addSubview:codeTextField];
        codeTextField.textColor = [UIColor blackColor];
        codeTextField.font = [UIFont systemFontOfSize:font14ScreenWRate * LKScreenW];
        codeTextField.placeholder = @"请输入验证码";
        codeTextField.backgroundColor = [UIColor clearColor];
        codeTextField.borderStyle = UITextBorderStyleNone;
        codeTextField.textAlignment = NSTextAlignmentLeft;
        codeTextField.keyboardType = UIKeyboardTypeNumberPad;
        codeTextField.autocapitalizationType = UITextAutocapitalizationTypeNone;
        codeTextField.keyboardAppearance=UIKeyboardAppearanceDefault;
        codeTextField.returnKeyType =UIReturnKeyDone;
        [codeTextField setClearButtonMode:UITextFieldViewModeNever];
        [codeTextField mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.phoneTextField);
            make.right.equalTo(self.codeButton.mas_left);
            make.centerY.equalTo(self.codeButton);
            if (isPhoneX) {
                make.height.equalTo(@(rateX812(20)));
            }else{
                make.height.equalTo(@(rate750(20)));
            }
            
        }];
        codeTextField.tintColor = [UIColor blackColor];
        codeTextField.delegate = self;
        
        
        _codeTextField = codeTextField;
    }
    return _codeTextField;
}

///**********密码下划线********///
-(UIView *)passLineView
{
    if (_passLineView == nil) {
        UIView *passLineView = [[UIView alloc] init];
        [self.view addSubview:passLineView];
        passLineView.backgroundColor = NumberColor(236, 231, 231);
        [passLineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.view).offset(rate375(20));
            make.right.equalTo(self.view).offset(-rate375(20));
            make.centerX.equalTo(self.view);
            make.height.equalTo(@1);
            if (isPhoneX) {
                make.top.equalTo(self.codeLineView.mas_bottom).offset(rateX812(52));
            }else{
                make.top.equalTo(self.codeLineView.mas_bottom).offset(rate750(52));
            }
        }];
        
        _passLineView = passLineView;
    }
    return _passLineView;
}
///*********密码图标*********///
-(UIImageView *)passImage
{
    if (_passImage == nil) {
        UIImageView *passImage = [[UIImageView alloc] init];
        [self.view addSubview:passImage];
        passImage.backgroundColor = [UIColor clearColor];
        passImage.image = [UIImage imageNamed:@"dl-mima"];
        passImage.contentMode = UIViewContentModeScaleToFill;
        [passImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.view).offset(rate375(25));
            make.width.equalTo(@(rate375(12)));
            if (isPhoneX) {
                make.height.equalTo(@(rateX812(16)));
                make.bottom.equalTo(self.passLineView.mas_top).offset(-rateX812(10));
            }else{
                make.height.equalTo(@(rate750(16)));
                make.bottom.equalTo(self.passLineView.mas_top).offset(-rate750(10));
            }
        }];
        _passImage = passImage;
    }
    return _passImage;
}
///*********密码可见按钮*********///
-(SYNoHeightedButton *)passButton
{
    if (_passButton == nil) {
        SYNoHeightedButton *passButton = [SYNoHeightedButton buttonWithType:UIButtonTypeCustom];
        [self.view addSubview:passButton];
        passButton.backgroundColor = [UIColor clearColor];
        [passButton setImage:[UIImage imageNamed:@"dl-yincang"] forState:UIControlStateNormal];
        [passButton setImage:[UIImage imageNamed:@"dl-xianshi"] forState:UIControlStateSelected];
        [passButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.view).offset(-rate375(25));
            make.centerY.equalTo(self.passImage);
            make.width.equalTo(@(rate375(50)));
            if (isPhoneX) {
                make.height.equalTo(@(rateX812(30)));
            }else{
                make.height.equalTo(@(rate750(30)));
            }
        }];
        [passButton addTarget:self action:@selector(passButtonClick:) forControlEvents:UIControlEventTouchDown];
        _passButton = passButton;
    }
    return _passButton;
}


-(void)passButtonClick:(SYNoHeightedButton *)button
{
    self.passButton.selected = !self.passButton.selected;
    if (self.passButton.selected) {
        self.passTextField.secureTextEntry = NO;
    }else{
        self.passTextField.secureTextEntry = YES;
    }
}
///*********密码输入框*********///
-(UITextField *)passTextField
{
    if (_passTextField == nil) {
        UITextField *passTextField = [[UITextField alloc] init];
        [self.view addSubview:passTextField];
        passTextField.textColor = [UIColor blackColor];
        passTextField.font = [UIFont systemFontOfSize:font14ScreenWRate * LKScreenW];
        passTextField.placeholder = @"请输入密码";
        passTextField.backgroundColor = [UIColor clearColor];
        passTextField.borderStyle = UITextBorderStyleNone;
        passTextField.textAlignment = NSTextAlignmentLeft;
        passTextField.keyboardType = UIKeyboardTypeDefault;
        passTextField.autocapitalizationType = UITextAutocapitalizationTypeNone;
        passTextField.keyboardAppearance=UIKeyboardAppearanceDefault;
        passTextField.returnKeyType =UIReturnKeyDone;
        [passTextField setClearButtonMode:UITextFieldViewModeWhileEditing];
        passTextField.secureTextEntry = YES;
        [passTextField mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.passImage);
            make.left.equalTo(self.passImage.mas_right).offset(rate375(13));
            make.right.equalTo(self.view).offset(-rate375(60));
            if (isPhoneX) {
                make.height.equalTo(@(rateX812(20)));
            }else{
                make.height.equalTo(@(rate750(20)));
            }
        }];
        passTextField.delegate = self;
        passTextField.tintColor = [UIColor blackColor];
        
        _passTextField = passTextField;
    }
    return _passTextField;
}
//密码输入提示文字
-(UILabel *)passPostLabel
{
    if (_passPostLabel == nil) {
        UILabel *passPostLabel = [[UILabel alloc] init];
        [self.view addSubview:passPostLabel];
        passPostLabel.textColor = NumberColor(173, 179, 193);
        passPostLabel.text = @"密码为6~12位数字和字母组合";
        passPostLabel.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        passPostLabel.textAlignment = NSTextAlignmentLeft;
        [passPostLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.view).offset(rate375(25));
            if (isPhoneX) {
                make.top.equalTo(self.passLineView.mas_bottom).offset(rateX812(10));
            }else{
                make.top.equalTo(self.passLineView.mas_bottom).offset(rate750(10));
            }
        }];
        _passPostLabel = passPostLabel;
    }
    return _passPostLabel;
}

-(SYNoHeightedButton *)sureButton
{
    if (_sureButton == nil) {
        SYNoHeightedButton *sureButton = [SYNoHeightedButton buttonWithType:UIButtonTypeCustom];
        [self.view addSubview:sureButton];
        [sureButton setBackgroundImage:[UIImage imageWithColor:zhidianAlprColor(0.3)] forState:UIControlStateDisabled];
        [sureButton setBackgroundImage:[UIImage imageWithColor:zhidainMainColor] forState:UIControlStateNormal];
        [sureButton setTitle:@"确认" forState:UIControlStateNormal];
        [sureButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [sureButton setTitleColor:[UIColor whiteColor] forState:UIControlStateDisabled];
        sureButton.titleLabel.font = [UIFont systemFontOfSize:font16ScreenWRate * LKScreenW];
        sureButton.titleLabel.textAlignment = NSTextAlignmentCenter;
        
        [sureButton mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.width.equalTo(@(rate375(284)));
            make.centerX.equalTo(self.view);
            if (isPhoneX) {
                make.height.equalTo(@(rateX812(48)));
                make.top.equalTo(self.passPostLabel.mas_bottom).offset(rateX812(38));
            }else{
                make.height.equalTo(@(rate750(48)));
                make.top.equalTo(self.passPostLabel.mas_bottom).offset(rate750(38));
            }
            
        }];
        sureButton.enabled = NO;
        [sureButton addTarget:self action:@selector(sureButtonClick:) forControlEvents:UIControlEventTouchDown];
        sureButton.layer.cornerRadius = 5.0f;
        sureButton.layer.masksToBounds = YES;
        
        _sureButton = sureButton;
    }
    return _sureButton;
}

@end
